package serializableTest;

import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.io.Serializable;

public class SerializableTestMain {

	/**
	 * @param args
	 * @throws Exception 
	 * @throws IOException 
	 */
	public static void main(String[] args) throws Exception  {
		//write();
		get();
	}
	
	
	public static void write()throws IOException{
		SerializeObj so = new SerializeObj();
		FileOutputStream fos = new FileOutputStream(new File("d://SerializeObj.txt"));
		ObjectOutputStream oos = new ObjectOutputStream(fos);
		oos.writeObject(so);
		fos.close();
		oos.close();
	}
	
	public static void get() throws Exception{
		SerializeObj so = null;
		File f = new File("d://SerializeObj.txt");
		FileInputStream fis = new FileInputStream(f);
		ObjectInputStream ois = new ObjectInputStream(fis);
	    so = (SerializeObj) ois.readObject();
		fis.close();
		ois.close();
		
		if(null != so){
			System.out.println(so.getClazzName());
		}
	}
	

}


class SerializeObj implements Serializable{
	private transient String clazzName = "SerializeObj";

	public String getClazzName() {
		return clazzName;
	}

	public void setClazzName(String clazzName) {
		this.clazzName = clazzName;
	}
}